package br.com.massai.model.entity.pojo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;

import br.com.massai.controller.annotations.Pojo;

@Embeddable
public class Employee implements Serializable {

	private static final long serialVersionUID = 8550189192759720143L;

	@Formula("0")
	private int dummy;

	@Column(name = "EMPLOYEE_EMP_CODIGO", length = 4, columnDefinition = "VARCHAR(4)")
	private String empCodigo;

	@Pojo
	@Column(name = "EMPLOYEE_EPG_CODIGO", length = 6, columnDefinition = "VARCHAR(6)")
	private String epgCodigo;

	@Column(name = "EMPLOYEE_NOME", length = 255, columnDefinition = "VARCHAR(255)")
	private String nome;

	@Column(name = "EMPLOYEE_CARGO_CODIGO", length = 3, columnDefinition = "VARCHAR(3)")
	private String cargoCodigo;

	@Column(name = "EMPLOYEE_CARGO", length = 255, columnDefinition = "VARCHAR(255)")
	private String cargo;

	@Column(name = "EMPLOYEE_CODIGO_DEPARTMENT", length = 30, columnDefinition = "VARCHAR(30)")
	private String codigoDepartment;
	
	@Transient
	private boolean selected;

	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;
		if(obj instanceof Employee)
			if(((Employee)obj).getEpgCodigo().equals(this.getEpgCodigo()) && ((Employee)obj).getEmpCodigo().equals(this.getEmpCodigo())) return true;
		return false;
	}

	@Override
	public String toString() {
		return new StringBuilder().append("[ ").append(Employee.class.getSimpleName()).append(" ]")
				.append(" ID: ").append(this.empCodigo).append(" - ").append(this.epgCodigo).toString();
	}

	public String getEmpCodigo() {
		return empCodigo;
	}

	public void setEmpCodigo(String empCodigo) {
		this.empCodigo = empCodigo;
	}

	public String getEpgCodigo() {
		return epgCodigo;
	}

	public void setEpgCodigo(String epgCodigo) {
		this.epgCodigo = epgCodigo;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getCargo() {
		return cargo;
	}

	public void setCargo(String cargo) {
		this.cargo = cargo;
	}

	public String getCodigoDepartment() {
		return codigoDepartment;
	}

	public void setCodigoDepartment(String codigoDepartment) {
		this.codigoDepartment = codigoDepartment;
	}

	public int getDummy() {
		return dummy;
	}

	public void setDummy(int dummy) {
		this.dummy = dummy;
	}

	public String getCargoCodigo() {
		return cargoCodigo;
	}

	public void setCargoCodigo(String cargoCodigo) {
		this.cargoCodigo = cargoCodigo;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}
}
